from random import randint

rand_nums = [ randint(1,21) for _ in range(20)]


uniq_set = set(rand_nums)

res = {}

for i in uniq_set:
    # 这样的效率不好
    res[i] = rand_nums.count(i)

print(sorted(res.items(), key=lambda x:x[1],reverse=True)[:3])

